/**
 * 
 */
package idv.takeshi.software.productline.bookstore.utils.invoice;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * A random invoice number generator.
 * @author takeshi
 *
 */
public class InvoiceNumberUtils {
	
	private InvoiceNumberUtils(){}
	
	/**
	 * Generate random 2 alphabetic chars and 8 digit chars as a invoice number.
	 * @return
	 */
	public static String generateRandomInvoiceNumber(){
		StringBuffer invoiceNumber = new StringBuffer();
		List<Integer> chars = new ArrayList<Integer>();
		List<Integer> digits = new ArrayList<Integer>();
		
		for(int a = 65; a <= 90; a++)
			chars.add(a);
		
		for(int a = 0; a < 10; a++)
			digits.add(a);
		
		Collections.shuffle(chars);
		Collections.shuffle(digits);
		
		for(int a = 0; a < 2; a++)
			invoiceNumber.append(((char) chars.get(a).intValue()));
		
		for(int a = 0; a < 8; a++)
			invoiceNumber.append("" + digits.get(a));
		
		return invoiceNumber.toString();
	}

}
